<?php
//使用post方式，向服务器发送json数据
$url='http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"]; 
$server=dirname($url)."/server.php";
$data = array ("username" => "bob","key" => "12345");


$curl = curl_init($server);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS,json_encode($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    "Content-Type: application/json"
));
$output = curl_exec($curl);
curl_close($curl);
echo $output;